.org 0xE7314 ; Partner_Boost

Partner_Boost:

	LDR 	R0, [SP, 4]	
	CMP		R0, 0
	BEQ		Sub_E73AC
	
	LDR 	R5, [Partner_Boost_1]
	LDR 	R4, [Partner_Boost_2]
	LDR 	R11, [Partner_Boost_6]

	MOV		R6, 0

Sub_E7330:	
	LDR 	R2, [R5, 0]
	LDR 	R0, [R4, 0]
	LDR		R1, [R7, R6, LSL 2]
	ADD		R0, R2, R0, LSL 2
	LDR		R2, [R0, 0x48]
	MOV		R0, R10
	ADD		R2, R2, 0x5000
	LDR		R2, [R2, 0xA58]
	ADD		R2, R8, R2
	ADD		R2, R2, R6, LSL 2
	STR		R1, [R2, 0x84]
	
	BL		PartnerBoost1
	
	CMP		R0, 0	
	BEQ		Sub_E73A0
	
	LDR 	R2, [R5, 0]
	LDR 	R1, [R4, 0]
	ADD		R0, R11, R10, LSL 5
	ADD		R1, R2, R1, LSL 2
	LDR		R2, [R1, 0x48]
	ADD		R1, R0, R6, LSL 2
	
	ADD		R0, R2, 0x5000
	LDR		R2, [R0, 0xA58]
	LDR		R0, [R1, 0x10]	
	ADD		R1, R8, R2
	ADD		R2, R1, R6, LSL 2
	LDR		R1, [R2, 0x84]
	ORR		R0, R1, R0
	STR		R0, [R2, 0x84]
	
Sub_E73A0:	
	ADD		R6, R6, 1
	
	CMP		R6, 4
	BLT		Sub_E7330

Sub_E73AC:	
	LDR 	R0, [SP, 0]	
	CMP		R0, 0
	ADDEQ	SP, SP, 0x1C
	
	POPEQ 	{R4-R11, LR}
	BXEQ	LR
	
;-------------------------------------------------------------------------------	

	MOV 	R0, CO_Synergy						; Skill: Conqueror
	STR		R0, [SP, 0xC]
	MOV 	R0, Rank_Synergy					; Rank: Conqueror	
	STR		R0, [SP, 0x8]	
	MOV 	R0, CO_Bodyguard					; Skill: Bodyguard
	STR		R0, [SP, 0x14]
	MOV 	R0, Rank_Bodyguard					; Rank: Bodyguard
		
	LDR 	R5, [Partner_Boost_1]
	LDR 	R4, [Partner_Boost_2]
	
	MOV		R7, 0
	MOV 	R11, CO_Teamwork					; Skill: Teamwork
	MOV 	R6, Rank_Teamwork					; Rank: Teamwork
	STR		R0, [SP, 0x10]

Sub_E73F4:
	LDR		R3, [R5, 0x0]
	LDR		R1, [R9, R7, LSL 2]
	LDR 	R2, [R4, 0]
	MOV		R0, R10
	ADD		R2, R3, R2, LSL 2
	LDR		R2, [R2, 0x48]	
	ADD		R2, R2, 0x5000
	LDR		R2, [R2, 0xA58]
	ADD		R2, R8, R2
	ADD		R2, R2, R7, LSL 2
	STR		R1, [R2, 0x74]
	
	BL		PartnerBoost1
	CMP		R0, 0
	BEQ		Sub_E756C
	
;-------------------------------------------------------------------------------	

	LDR 	R2, [R5, 0]
	LDR 	R1, [R4, 0]
	LDR 	R0, [Partner_Boost_6]
	ADD		R1, R2, R1, LSL 2
	ADD		R0, R0, R10, LSL 5
	LDR		R1, [R1, 0x48]
	LDR		R2, [R0, R7, LSL 2]
	ADD		R0, R1, 0x5000
	LDR		R0, [R0, 0xA58]
	MOV		R1, R6
	ADD		R0, R8, R0
	ADD		R3, R0, R7, LSL 2
	LDR		R0, [R3, 0x74]
	ORR		R0, R0, R2
	STR		R0, [R3, 0x74]
	LDR		R2, [R5, 0x0]
	LDR		R0, [R4, 0x0]
	ADD		R0, R2, R0, LSL 2
	LDR		R0, [R0, 0x48]
	ADD		R0, R0, 0x5000
	LDR		R0, [R0, 0xA58]
	ADD		R0, R0, R8
	ADD		R0, R0, 0x84
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped
	CMP 	R0, 0								; Does CO use that skill?
	BEQ		Sub_E74BC
	
	LDR		R2, [R5, 0]
	LDR		R0, [R4, 0]
	MOV		R1, R11
	ADD		R0, R2, R0, LSL 2
	LDR		R0, [R0, 0x48]
	ADD		R0, R0, 0x5000
	LDR		R0, [R0, 0xA58]
	ADD		R0, R0, R8
	ADD		R0, R0, 0x74
	BL		PartnerBoost2
	
Sub_E74BC:
	LDR		R2, [R5, 0]
	LDR		R0, [R4, 0]
	LDR		R1, [SP, 0x8]
	ADD		R0, R2, R0, LSL 2
	LDR		R0, [R0, 0x48]
	ADD		R0, R0, 0x5000
	LDR		R0, [R0, 0xA58]
	ADD		R0, R0, R8
	ADD		R0, R0, 0x84
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped
	CMP 	R0, 0								; Does CO use that skill?
	BEQ		Sub_E7514
	
	LDR		R2, [R5, 0]
	LDR		R0, [R4, 0]
	LDR		R1, [SP, 0xC]
	ADD		R0, R2, R0, LSL 2
	LDR		R0, [R0, 0x48]
	ADD		R0, R0, 0x5000
	LDR		R0, [R0, 0xA58]
	ADD		R0, R0, R8
	ADD		R0, R0, 0x74
	
	BL		PartnerBoost2
	
Sub_E7514:
	LDR		R2, [R5, 0]
	LDR		R0, [R4, 0]
	LDR		R1, [SP, 0x10]
	ADD		R0, R2, R0, LSL 2
	LDR		R0, [R0, 0x48]
	ADD		R0, R0, 0x5000
	LDR		R0, [R0, 0xA58]
	ADD		R0, R0, R8
	ADD		R0, R0, 0x84
	
	BL 		Check_Skills_Equipped				; Check the Skill is equipped
	CMP 	R0, 0								; Does CO use that skill?
	BEQ		Sub_E756C
	
	LDR		R2, [R5, 0]
	LDR		R0, [R4, 0]
	LDR		R1, [SP, 0x14]
	ADD		R0, R2, R0, LSL 2
	LDR		R0, [R0, 0x48]
	ADD		R0, R0, 0x5000
	LDR		R0, [R0, 0xA58]
	ADD		R0, R0, R8
	ADD		R0, R0, 0x74
	BL		PartnerBoost2
	
Sub_E756C:
	ADD		R7, R7, 1
	CMP		R7, 4
	BLT		Sub_E73F4
	
	ADD		SP, SP, 0x1C
	
	POP 	{R4-R11, LR}
	BX 		LR

;-------------------------------------------------------------------------------		

Partner_Boost_1:
	.dw Reg1_Skill
	
Partner_Boost_2:
	.dw Reg2_Skill
	
Partner_Boost_3:
	.dw Reg3_Skill
	
Partner_Boost_4:
	.dw Reg0_Skill

Partner_Boost_5:
	.dw 0x02183B08
	
Partner_Boost_6:
	.dw 0x022A72C8
	
;-------------------------------------------------------------------------------

.org 0xE7054
PartnerBoost1:

.org 0xE7EB4
PartnerBoost2:

